[t:/]$ 지식_

dlopen으로 shared 라이브러리의 demand on loading

2011/10/06

http://linux.die.net/man/3/dlopen

.so를 다 로딩 안 하고 dlopen로 런타임에 연다. 필요한 펑션은 심볼을 통해서 받아 쓴다. 윈도우 dll과 비슷.

잘쓰면 어플의 초기 기동을 빠르게 할 수 있는데.. 생각보다 잘 안 쓰더라 -_-;

dlopen, dlclose 이 리턴하기 바로 전에는 생성자와 파괴자가 자동 호출 되는데.. 이렇게 하랜다.

Using these routines, or the gcc -nostartfiles or -nostdlib options, is not recommended. Their use may result in undesired behavior, since the constructor/destructor routines will not be executed (unless special measures are taken).

Instead, libraries should export routines using the __attribute__((constructor)) and __attribute__((destructor)) 

실제적으로는 옵션 달고 컴파일 한 것만 본 것 같다.

dl_iterate_phd // 공유 라이브러리 찾아 들어갈때의 콜백 함수..
http://linux.die.net/man/3/dl_iterate_phdr

ld.so를 잘 보면 많은 것이 보인다.

http://linux.die.net/man/8/ld.so





공유하기













[t:/] is not "technology - root". dawnsea, rss